<?php
header('Content-Type: text/html;charset=UTF-8');
$link = mysqli_connect('localhost', 'root', '', 'simplyproject');

$task_id = $_POST['id']; 
$result = mysqli_query($link, "SELECT * FROM task WHERE id_task = $task_id");

// Vérif si task appartient au projet

$task = mysqli_fetch_array($result);

?>

<div id="edit_task">

<span class="add_task">Add task ?</span>

<form action="" method="post">
	
	<label for="title_task">Title : </label>
	<input id="title_task" name="title_task" type="text" value="<?php echo $task['title']; ?>"/><br/><br/>
	
	<label for="start_date_task">Start date : </label>
	<?php 
	$start_date = explode("-", $task['start_date']);
	?> 
	<input id="start_date_task" name="start_date_task" type="text" value="<?php echo date("d/m/Y", mktime(0, 0, 0, $start_date[1], $start_date[2], $start_date[0])); ?>"/><br/><br/>
	<?php 
	$end_date = explode("-", $task['end_date']); 
	?> 	
	<label for="end_date_task">End date : </label>
	<input id="end_date_task" name="end_date_task" type="text" value="<?php echo date("d/m/Y", mktime(0, 0, 0, $end_date[1], $end_date[2], $end_date[0])); ?>"/><br/><br/>
			
	<label for="description_task">Description : </label><br/>
	<textarea id="description_task" name="description_task"><?php echo $task['description'] ?></textarea><br/><br/>
	
	<input type="hidden" name="id" value="<?php echo $task['id_task']; ?>" />
	
	<input type="submit" value="Envoyer" />
</form>


</div>